

/*
 *check data when submit 
 *
 *
 */
jQuery("#tb-search-flights").click(function() {

    var dataTrue = 1;
    var typeFlights = 0;
    var siteUrl = jQuery('#site_url').val();
    
    var url_ajax = siteUrl+"/wp-content/themes/travel_donald/ajax/request_a_quote.php";
    
    //var typeFlights1 = jQuery('#typeFlights1').checked ; 
    /// alert(typeFlights1);
    if (jQuery('#typeFlights1').is(":checked"))
    {
        typeFlights = 1;
        
    }
    if (jQuery('#typeFlights2').is(":checked"))
    {
        typeFlights = 2;
        
    }
    if (jQuery('#typeFlights3').is(":checked"))
    {
        typeFlights = 3;
        
    }
    if(typeFlights == '0'){
        
        jQuery("#error-type-flight").html('Please you check type flights');
          dataTrue = 0;
    }
    else{
        jQuery("#error-type-flight").html('');
    }
    var startLocation =  jQuery('#leaving-from').val();
    if(startLocation  == ""){
        jQuery("#error-leaving-form").html('Leaving from must not be  blank');
        dataTrue = 0;
        
    }else{ 
        jQuery("#error-leaving-form").html('');
    }
    
    var endLocation   =  jQuery('#going-to').val();
    if(endLocation == "")
    {
        jQuery('#error-going-to').html('Going to must not be blank');
        dataTrue = 0;
    }
    else
    {
        jQuery("#error-going-to").html(''); 
        
    }
    var startDate     =  jQuery('#departure-date').val();
    if(startDate == ""){ 
        jQuery("#error-start-time").html('Departure date must not be blank<br/>');
        dataTrue = 0;
    }
    else{
        jQuery("#error-start-time").html("");
    }
    
    var endDate       =  jQuery("#return-date").val();
    if(endDate == ""){
        
         jQuery("#error-end-time").html('Return date must not be blank');
         dataTrue = 0;
    }
    else{
        jQuery('#error-end-time').html("");
        
    }
    
    var adult         =  jQuery("#Adult").val();
    var children      =  jQuery('#numCHD').val();
    var infant        =  jQuery("#infant").val();
    var classa        =  jQuery("#class").val();
    var city          =  jQuery("#city").val();
    if(dataTrue == 1){
        
       $.post(url_ajax, {typeFlights: typeFlights,startLocation:startLocation,endLocation:endLocation,startDate:startDate,
           endDate:endDate,adult:adult,children:children,infant:infant,class:classa,city:city}, function(data) {
            
           // alert('');
           jQuery("#success-request_quote").modal();
            
       });
       
       
    }
    
    
    
});